package com.ny.demo;

public class JNJK {
    public static void main(String[] args) {
                Vehicle[] vehicles = new Vehicle[4];

                // 初始化数组，创建几个 Car 和 Bike 对象
                vehicles[0] = new Car("Toyota", "Corolla");
                vehicles[1] = new Bike("Yamaha", "MT-09");
                vehicles[2] = new Car("Ford", "Mustang");
                vehicles[3] = new Bike("Harley", "Street 750");

                // 使用循环遍历数组，并通过多态性调用每个对象的 drive 方法
                for (Vehicle vehicle : vehicles) {
                    vehicle.drive();
                }
            }
    }

